package com.caifeng.domain;

import com.caifeng.domain.vo.DefaultVO;
import lombok.Getter;

/**
 * 业务异常类，继承运行时异常，确保事务正常回滚
 */

@Getter
public class ServiceException extends RuntimeException{

    private final ResponseCode code;
    private final DefaultVO description;

    public ServiceException(ResponseCode code) {
        this.code = code;
        this.description = DefaultVO.fail();
    }

    public ServiceException(String description) {
        this.code = ResponseCode.FAIL;
        this.description = DefaultVO.of(description);
    }

    public ServiceException(ResponseCode code, String description) {
        this.code = code;
        this.description = DefaultVO.of(description);
    }
}